using System.Web.Mvc;
using SubSonic.SqlGeneration.Schema;

namespace Webbness.Mvc.Models
{
    public class SecurityUserInRole<TRole, TJoin, TUser> : Record
        where TUser : SecurityUser<TUser, TJoin, TRole>, new()
        where TRole : SecurityRole<TRole, TJoin, TUser>, new()
        where TJoin : SecurityUserInRole<TRole, TJoin, TUser>, new()
    {
        [SubSonicPrimaryKey]
        [HiddenInput]
        public override int Id { get; set; }

        public virtual int UserID { get; set; }

        public virtual int RoleID { get; set; }

        public virtual TRole Role
        {
            get { return GetForeign<TRole>(RoleID); }
            set { RoleID = SetForeign(value); }
        }

        public virtual TUser User
        {
            get { return GetForeign<TUser>(UserID); }
            set { UserID = SetForeign(value); }
        }
    }
}